<?php
/*
 * @ https://EasyToYou.eu - IonCube v11 Decoder Online
 * @ PHP 7.2 & 7.3
 * @ Decoder version: 1.1.6
 * @ Release: 10/08/2022
 */

// Decoded file for php version 71.
namespace Mdanter\Ecc\Serializer\Util;

class CurveOidMapper
{
    private static $sizeMap;
    private static $oidMap;
    const NIST_P192_OID = "1.2.840.10045.3.1.1";
    const NIST_P224_OID = "1.3.132.0.33";
    const NIST_P256_OID = "1.2.840.10045.3.1.7";
    const NIST_P384_OID = "1.3.132.0.34";
    const NIST_P521_OID = "1.3.132.0.35";
    const SECP_112R1_OID = "1.3.132.0.6";
    const SECP_192K1_OID = "1.3.132.0.31";
    const SECP_256K1_OID = "1.3.132.0.10";
    const SECP_256R1_OID = "1.2.840.10045.3.1.7";
    const SECP_384R1_OID = "1.3.132.0.34";
    const SM2_OID = "1.2.156.10197.1.301";
    public static function getNames() : array
    {
        return array_keys(self::$oidMap);
    }
    public static function getByteSize($curve)
    {
        if($curve instanceof \Mdanter\Ecc\Curves\NamedCurveFp && array_key_exists($curve->getName(), self::$sizeMap)) {
            return self::$sizeMap[$curve->getName()];
        }
        throw new \Mdanter\Ecc\Exception\UnsupportedCurveException("Unsupported curve type");
    }
    public static function getCurveOid($ObjectIdentifier, $curve)
    {
        if(array_key_exists($curve->getName(), self::$oidMap)) {
            $oidString = self::$oidMap[$curve->getName()];
            return new \FG\ASN1\Universal\ObjectIdentifier($oidString);
        }
        throw new \Mdanter\Ecc\Exception\UnsupportedCurveException("Unsupported curve type");
    }
    public static function getCurveFromOid($NamedCurveFp, $oid)
    {
        $oidString = $oid->getContent();
        $invertedMap = array_flip(self::$oidMap);
        if(array_key_exists($oidString, $invertedMap)) {
            return \Mdanter\Ecc\Curves\CurveFactory::getCurveByName($invertedMap[$oidString]);
        }
        $error = new \Mdanter\Ecc\Exception\UnsupportedCurveException("Invalid data: unsupported curve.");
        $error->setOid($oidString);
        throw $error;
    }
    public static function getGeneratorFromOid($GeneratorPoint, $oid)
    {
        $oidString = $oid->getContent();
        $invertedMap = array_flip(self::$oidMap);
        if(array_key_exists($oidString, $invertedMap)) {
            return \Mdanter\Ecc\Curves\CurveFactory::getGeneratorByName($invertedMap[$oidString]);
        }
        $error = new \Mdanter\Ecc\Exception\UnsupportedCurveException("Invalid data: unsupported generator.");
        $error->setOid($oidString);
        throw $error;
    }
}

?>